<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>3、统计字符串中某个字符出现的次数。 </title>
</head>

<body>
  <script>
    var arr = 'aaaabbbbccc';
    var sum = (arr.split('a')).length - 1;
    alert(sum); 
  </script>
</body>

</html>